#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n), vis(m, 0);
    priority_queue<int,vector<int>,greater<int>> pqa, tpqa;
    vector<pii> b(m);
    for(int i = 0 ; i < n; i++){
    	cin >> a[i];
    	pqa.push(a[i]);
    }
    for(int i = 0 ; i < m; i++){
    	cin >> b[i].first;
    }
	for(int i = 0 ; i < m; i++){
    	cin >> b[i].second;
    }

    sort(b.begin(), b.end(), [&](pii& a, pii& b){
    	if(a.first == b.first)return a.second > b.second;
    	return a.first < b.first;
    });

    int ind = 0;
    while(ind < m && b[ind].second == 0)ind++;

    while(!pqa.empty() && ind < m){
    	int p = pqa.top();
    	pqa.pop();
    	if(p >= b[ind].first){
    		p = max(p, b[ind].second);
    		pqa.push(p);
    		vis[ind] = 1;
    		ind++;
    		while(ind < m && b[ind].second == 0)ind++;
    		if(ind == m){
    			break;
    		}
    	}else{
    		tpqa.push(p);
    	}
    }

    while(!pqa.empty()){
    	int p = pqa.top();
    	pqa.pop();
    	tpqa.push(p);
    }

    int p = tpqa.top();
    tpqa.pop();
    for(int i = 0; i < m; i++){
        if(vis[i]) continue;
        while(!tpqa.empty() && p < b[i].first){
            p = tpqa.top();
            tpqa.pop();
        }
        if(p >= b[i].first){
            vis[i] = 1;
        }
        if(!tpqa.empty()){
            p = tpqa.top();
            tpqa.pop();
        }else{
            break;
        }
    }

    int res = 0;
    for(int& x : vis)if(x)res++;
    cout << res << '\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}